From: Marina Zhurakhinskaya Date: Thu, 13 Aug 2009 00:02:59 +0000 (-0400) Subject: Make dragging an item to the Add Workspace button launch it on a new workspace X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~11085 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=fb0ca1ba9de709a0911f34bb1687a2eb5ff3450a;p=gnome-shell.git Make dragging an item to the Add Workspace button launch it on a new workspace It is convenient to drag an item to the Add Workspace button and have it be launched on a new workspace. Based on a patch from Josh Adams. --- diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js index 0618518c2..7802505f4 100644 --- a/js/ui/workspaces.js +++ b/js/ui/workspaces.js @@ -894,18 +894,15 @@ Workspaces.prototype = { activeWorkspace.actor.raise_top(); this._positionWorkspaces(global, activeWorkspace); - // Create (+) button + // Save the button size as a global variable so we can us it to create + // matching button sizes for workspace remove buttons. buttonSize = addButtonSize; - this.addButton = new Clutter.Texture({ x: addButtonX, - y: addButtonY, - width: buttonSize, - height: buttonSize, - reactive: true - }); - this.addButton.set_from_file(global.imagedir + "add-workspace.svg"); - this.addButton.connect('button-release-event', this._appendNewWorkspace); - this.actor.add_actor(this.addButton); - this.addButton.lower_bottom(); + + // Create (+) button + this.addButton = new AddWorkspaceButton(addButtonSize, addButtonX, addButtonY, Lang.bind(this, this._addWorkspaceAcceptDrop)); + this.addButton.actor.connect('button-release-event', Lang.bind(this, this._appendNewWorkspace)); + this.actor.add_actor(this.addButton.actor); + this.addButton.actor.lower_bottom(); let lastWorkspace = this._workspaces[this._workspaces.length - 1]; lastWorkspace.updateRemovable(true); @@ -1132,10 +1129,39 @@ Workspaces.prototype = { this.actor.add_actor(workspace.actor); }, - _appendNewWorkspace : function(actor, event) { + _appendNewWorkspace : function() { + let global = Shell.Global.get(); + + global.screen.append_new_workspace(false, global.screen.get_display().get_current_time()); + }, + + // Creates a new workspace and drops the dropActor there + _addWorkspaceAcceptDrop : function(source, dropActor, x, y, time) { + this._appendNewWorkspace(); + return this._workspaces[this._workspaces.length - 1].acceptDrop(source, dropActor, x, y, time); + } +}; + +function AddWorkspaceButton(buttonSize, buttonX, buttonY, acceptDropCallback) { + this._init(buttonSize, buttonX, buttonY, acceptDropCallback); +} + +AddWorkspaceButton.prototype = { + _init : function(buttonSize, buttonX, buttonY, acceptDropCallback) { + this.actor = new Clutter.Texture({ x: buttonX, + y: buttonY, + width: buttonSize, + height: buttonSize, + reactive: true }); + this._acceptDropCallback = acceptDropCallback; let global = Shell.Global.get(); + this.actor._delegate = this; + this.actor.set_from_file(global.imagedir + 'add-workspace.svg'); + }, - global.screen.append_new_workspace(false, event.get_time()); + // Draggable target interface + acceptDrop : function(source, actor, x, y, time) { + return this._acceptDropCallback(source, actor, x, y, time); } };